import os
import pickle
os.getcwd()
os.chdir('C:\\Users\\shenhua\\Desktop\\HeadFirstPython\\Chapter3')
os.getcwd()
try:
	data=open('sketch.txt')
	print('链接到')
	data.seek(0)
	man=[]
	other=[]
	for each_line in data:
		try:
			(role,line_spoken)=each_line.split(':',1)
			line_spoken.strip()
			if role=='Man':
				man.append(line_spoken)
			elif role=='Other Man':
				other.append(line_spoken)
		except ValueError:
			pass
	data.close()
except IOError:
	print('miss txt')
try:
	with open("C:\\Users\\shenhua\\Desktop\\HeadFirstPython\\chapter4\\man_data1.txt",'wb') as man_file:
		pickle.dump(man,man_file)
	with open("C:\\Users\\shenhua\\Desktop\\HeadFirstPython\\chapter4\\other_data1.txt",'wb') as other_file:
		pickle.dump(other,other_file)
except IOError as er:
	print('IOError   '+str(er))
except pickle.PickleError as per:
	print('PError :'+str(er))